//
//  YZSickerMessageView.m
//  患者信息界面（代码）
//
//  Created by Yip-Jun on 16/5/9.
//  Copyright © 2016年 YIPWJ. All rights reserved.
//

#import "YZSickerMessageView.h"
#import "Masonry.h"

@interface YZSickerMessageView ()

@property (nonatomic, strong) UIView *grayView;
@property (nonatomic, strong) UIImageView *sickerImageView;
@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *sickLabel;
@property (nonatomic, strong) UILabel *diagnoseLabel;
@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation YZSickerMessageView

+ (instancetype)sickerMessageView {
    YZSickerMessageView *sickerView = [[YZSickerMessageView alloc] init];
//    sickerView.frame = CGRectMake(100, 0, 100, 100);
    [sickerView prepareUI];
    [sickerView setSubviewsFrame];
    
    return sickerView;
}

- (void)prepareUI {
    
    [self addSubview:self.grayView];
    [self.grayView addSubview:self.sickerImageView];
    [self.grayView addSubview:self.titleLabel];
    
    [self addSubview:self.nameLabel];
    [self addSubview:self.sickLabel];
    [self addSubview:self.diagnoseLabel];
    [self addSubview:self.timeLabel];
}

- (void)setSubviewsFrame {
    
    [self.grayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.equalTo(self);
        make.height.mas_equalTo(30);
    }];
    
    [self.sickerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.grayView);
        make.leading.mas_equalTo(16);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.grayView);
        make.leading.equalTo(self.sickerImageView.mas_trailing).offset(16);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.grayView.mas_bottom).offset(8);
        make.leading.equalTo(self).offset(16);
    }];
    
    [self.sickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self).offset(-8);
        make.top.equalTo(self.nameLabel);
    }];
    
    [self.diagnoseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self).offset(-8);
        make.leading.equalTo(self.nameLabel);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self).offset(-8);
        make.bottom.equalTo(self.diagnoseLabel);
    }];
}

#pragma mark - 懒加载
- (UIView *)grayView {
    if (!_grayView) {
        _grayView = [[UIView alloc] init];
        _grayView.backgroundColor = [UIColor lightGrayColor];
    }
    return _grayView;
}

- (UIImageView *)sickerImageView {
    if (!_sickerImageView) {
        _sickerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"product_img_icon_xieyi.png"]];
    }
    return _sickerImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.text = @"患者信息";
    }
    return _titleLabel;
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.text = @"安";
        _nameLabel.font = [UIFont systemFontOfSize:16];
    }
    return _nameLabel;
}

- (UILabel *)sickLabel {
    if (!_sickLabel) {
        _sickLabel = [[UILabel alloc] init];
        _sickLabel.text = @"心血管（已确诊）";
        _sickLabel.textAlignment = NSTextAlignmentCenter;
        _sickLabel.font = [UIFont systemFontOfSize:16];
    }
    return _sickLabel;
}

- (UILabel *)diagnoseLabel {
    if (!_diagnoseLabel) {
        _diagnoseLabel = [[UILabel alloc] init];
        _diagnoseLabel.text = @"未接受过";
        _diagnoseLabel.font = [UIFont systemFontOfSize:16];
    }
    return _diagnoseLabel;
}

- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.text = @"就诊时间：2016-01-28 下午";
        _timeLabel.font = [UIFont systemFontOfSize:16];
    }
    return _timeLabel;
}

@end
